Information to be manipulated using a computer system may be stored in a database. A database is a collection of information and may be arranged with certain data grouped into one or more records. For example, an employee database may contain the name, manager's name and salary of each employee in a company. This information may be arranged in a database using a separate record for each employee, with each record capable of storing a name, manager's name and salary. The information for each employee may be entered into the records to build a table, and one or more tables is used to build a database. As new employees join the company and old employees depart the company, the database may be changed by one or more users to maintain the information stored in the database. Conventional database programs such as Access, commercially available from Microsoft Corporation of Redmond, Wash., Lotus Approach, commercially available from IBM Corporation of Armonk, N.Y., and Filemaker, commercially available from Claris Corporation of Cupertino, Calif. may be used to implement databases, the Oracle 7 product commercially available from Oracle Corporation of Redwood Shores, Calif. may be purchased to implement a client-server database, or a database may be programmed using conventional programming languages such as C, Pascal or Basic and conventional database programming techniques.
Some databases are maintained in such a manner that all data in the database is current. For example, when an employee leaves the employ of the company, the record corresponding to the employee may be deleted from the database. Referring now to FIG. 1A, a table 100 in a database that contains the name 120, salary 122 and manager 124 of each employee in a company is shown. There are two rows 110, 112, one for each employee in the company. Each row 110, 112 corresponds to a record in the table 100 and the table 100 is the database.
Information is retrieved from a database using a form of retrieve command. In many conventional databases products, the retrieve command is implemented in a structured format known as a query. Queries that comply with a set of standards are referred to as "SQL queries". Other conventional databases use other types of commands, such as a "find," and still others use both the find and query approaches. As used herein, "query" includes queries, finds or other requests for data made to a server. To identify the number of employees of the company, a query may be made to identify and count the employees in the table 100. Conventional query or find commands allow a novice user to quickly locate and summarize data without substantial training.
For example, to identify the managers who made less than all of their employees, an SQL query could be applied to the employee table 100 as follows:
______________________________________ SELECT Name FROM Employee E1 WHERE NOT EXISTS (SELECT * FROM Employee E2 WHERE E1.Name = E2.Manager AND E1.Salary &gt;= E2.Salary) AND EXISTS (SELECT * FROM Employee E3 WHERE E1.Name = E3.Manager AND E1.Salary &lt; E3.Salary) (Query 1) ______________________________________
The result of this query will be a list of managers names corresponding to managers who make less than all of their employees.
It is often desirable to maintain information that is not current in a database. For example for tax purposes, additional fields may be added to each record in the database to allow information that is not current to nevertheless be maintained. For example, a "StartDate" field and an "StopDate" field could be added to each employee record to indicate the dates during which an employee had a specified salary and manager. Referring now to FIG. 1B, the employee table 100 of FIG. 1A can be modified as table 150 to capture historical data by adding the StartDate and StopDate columns 126, 128 to indicate a period during which the data in the row 160, 162, 164, 166 is or was valid. Table 150 contains all the values of the data in the database, not just the current values. Thus, table 150 contains different values of the data in the database over time. It is possible for the StartDate and StopDate columns 126, 128 to contain dates in the future, for example to store planning data in the table 150.
It may be desirable to identify any manager that made less than all of the manager's employees during any period of time, and to also identify the period of time in which this situation was valid. One method of identifying this information would be to select data from the table 150 that has a StartDate and a StopDate that contains a specified day, then test the condition using the query above, and repeat this process for every day during which data in the table 150 is valid. Such a process would require numerous queries to the database, using processing resources that might be expended performing other tasks. It is desirable to identify a way of obtaining information from a database that accommodates different values of the data according to a variable such as time, while minimizing the number of queries made to the database and is independent of the precision (e.g. day, second, microsecond) of the variable.